package com.chb.docter.controller.apis;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chb.docter.dto.AppRegistrationDto;
import com.chb.docter.dto.MyPage;
import com.chb.docter.dto.OrderDetailsDto;
import com.chb.docter.dto.OrderListDto;
import com.chb.docter.params.RegistrationParam;
import com.chb.docter.params.RegistrationQueryParam;
import com.chb.docter.service.RegistrationService;
import com.hos.entity.his.Registration;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 陈海彬
 * @date: Created in 2023/12/13 9:49
 * @description:
 * @modified By:
 * @version:
 */
@RestController
@RequestMapping("docter/api/registration")
@Api(tags = "挂号信息相关接口", value = "挂号接口")
@Slf4j
public class ApiRegistrationController {

    @Resource
    private RegistrationService registrationService;

    @PostMapping("addRegistration")
    @ApiOperation("提交挂号信息")
    public Result<String> addRegistration(@RequestBody RegistrationParam registrationParam) {
        return new Result<>(200, "提交成功", registrationService.addRegistration(registrationParam));
    }


    @PostMapping("collectFee/{registrationId}")
    @ApiOperation("进行挂号收费")
    public Result<Void> collectFee(@PathVariable String registrationId) {
        registrationService.collectFee(registrationId);
        return new Result<>(200, "收费成功", null);
    }

    @PostMapping("doInvalid/{registrationId}")
    @ApiOperation("进行挂号作废")
    public Result<Void> doInvalid(@PathVariable String registrationId) {
        registrationService.doInvalid(registrationId);
        return new Result<>(200, "收费成功", null);
    }

    @PostMapping("doReturn/{registrationId}")
    @ApiOperation("进行挂号退号")
    public Result<Void> doReturn(@PathVariable String registrationId) {
        registrationService.doReturn(registrationId);
        return new Result<>(200, "收费成功", null);
    }

    @PostMapping("queryRegistrationForPage")
    @ApiOperation("分页查询挂号信息")
    public Result<Page<Registration>> queryRegistrationForPage(@RequestBody RegistrationQueryParam param) {
        return new Result<>(200, "查询成功", registrationService.queryRegistrationForPage(param));
    }


    @GetMapping("queryToBeSeenRegistration/{schedulingType}")
    @ApiOperation("加载挂号列表[待就诊]")
    public Result<List<Registration>> queryToBeSeenRegistration(@PathVariable String schedulingType) {
        return new Result<>(200, "查询成功", registrationService.queryToBeSeenRegistration(schedulingType));
    }

    @GetMapping("queryVisitingRegistration/{schedulingType}")
    @ApiOperation("加载挂号列表[就诊中]")
    public Result<List<Registration>> queryVisitingRegistration(@PathVariable String schedulingType) {
        return new Result<>(200, "查询成功", registrationService.queryVisitingRegistration(schedulingType));
    }

    @GetMapping("queryVisitCompletedRegistration/{schedulingType}")
    @ApiOperation("加载挂号列表[就诊完成]")
    public Result<List<Registration>> queryVisitCompletedRegistration(@PathVariable String schedulingType) {
        return new Result<>(200, "查询成功", registrationService.queryVisitCompletedRegistration(schedulingType));
    }


    @PostMapping("receivePatient/{registrationId}")
    @ApiOperation("进行接诊")
    public Result<Integer> receivePatient(@PathVariable String registrationId) {
        return new Result<>(200, "接诊成功", registrationService.receivePatient(registrationId));
    }


    @GetMapping("getRegistrationByStatus")
    @ApiOperation("获取挂号列表")
    public Result<MyPage<OrderListDto>> getRegistrationByStatus(Integer page, Integer pageSize, String orderState) {
        return new Result<>(200, "查询成功", this.registrationService.getRegistrationByStatus(page, pageSize, orderState));
    }


    @GetMapping("getRegistrationListByStatus")
    @ApiOperation("根据状态查询挂号列表")
    public Result<MyPage<OrderListDto>> getRegistrationListByStatus(Integer page, Integer pageSize,String orderState) {
        return new Result<>(200, "查询成功", this.registrationService.getRegistrationListAsStatus(page,pageSize,orderState));
    }
    @PostMapping("addAppRegistration")
    @ApiOperation("手机端提交挂号信息")
    public Result<String> addAppRegistration(@RequestBody AppRegistrationDto appRegistrationDto) {
        return new Result<>(200, "提交成功", registrationService.addAppRegistration(appRegistrationDto));
    }
}